package Eyjafjalla.card.attack;

import Eyjafjalla.action.EyjafjallaAttackAction;
import Eyjafjalla.action.PulseAction;
import Eyjafjalla.card.AbstractEyjafjallaCard;
import Eyjafjalla.modcore.EyjafjallaTag;
import Eyjafjalla.patch.FirePatch;
import basemod.abstracts.AbstractCardModifier;
import basemod.helpers.CardModifierManager;
import com.badlogic.gdx.graphics.Color;
import com.megacrit.cardcrawl.actions.AbstractGameAction;
import com.megacrit.cardcrawl.actions.common.DamageAction;
import com.megacrit.cardcrawl.actions.common.GainBlockAction;
import com.megacrit.cardcrawl.actions.common.GainEnergyAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.localization.CardStrings;
import com.megacrit.cardcrawl.monsters.AbstractMonster;
import com.megacrit.cardcrawl.powers.AbstractPower;
import com.megacrit.cardcrawl.powers.watcher.VigorPower;

public class PulseOfTerra_Eyjafjalla extends AbstractEyjafjallaCard {
    public static final String ID = "PulseOfTerra_Eyjafjalla";
    private static final CardStrings cardStrings;

    public PulseOfTerra_Eyjafjalla(){
        super(ID, cardStrings.NAME,1,cardStrings.DESCRIPTION,CardType.ATTACK,CardRarity.RARE,CardTarget.ENEMY);
        this.baseDamage = 3;
        this.damage =3;
        this.baseBlock = 3;
        this.block = 3;
        this.baseMagicNumber = 2;
        this.magicNumber = 2;
        this.baseFire = 0;
        this.fire = 0;
        tags.add(EyjafjallaTag.UNLIMITED_FIRE_EYJAFJALLA);
        setFireDescription(cardStrings.EXTENDED_DESCRIPTION[0]);
    }

    @Override
    public AbstractCard makeCopy() {
        return new PulseOfTerra_Eyjafjalla();
    }

    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {
        addToBot(new EyjafjallaAttackAction());
        for(int i =0;i<magicNumber;i++){
            addToBot(new GainBlockAction(p,block));
        }
        for(int i =0;i<magicNumber;i++){
            addToBot(new DamageAction(m,new DamageInfo(p,damage,damageTypeForTurn), AbstractGameAction.AttackEffect.FIRE));
        }
    }

    @Override
    public void triggerOnGlowCheck() {
        this.glowColor = Color.RED.cpy();
    }

    @Override
    protected void applyPowersToBlock() {
        int trueB = baseBlock;
        baseBlock+= baseFire;
        super.applyPowersToBlock();
        baseBlock = trueB;
        isBlockModified = baseBlock!=block;
    }

    @Override
    public void calculateCardDamage(AbstractMonster mo) {
        int trueD = baseDamage;
        int trueF = baseFire;
        baseFire +=FirePatch.fireMarkAmount;
        baseDamage+= baseFire;
        super.calculateCardDamage(mo);
        baseDamage = trueD;
        fire = baseFire;
        baseFire = trueF;
        isFireModified = baseFire!=fire;
        isDamageModified = baseDamage!=damage;
    }

    @Override
    public void applyPowers() {
        int trueD = baseDamage;
        int trueF = baseFire;
        baseFire +=FirePatch.fireMarkAmount;
        baseDamage+= baseFire;
        super.applyPowers();
        baseDamage = trueD;
        fire = baseFire;
        baseFire = trueF;
        isFireModified = baseFire!=fire;
        isDamageModified = baseDamage!=damage;
    }

    @Override
    public void upgrade() {
        if(!this.upgraded){
            upgradeName();
            upgradeDamage(2);
            upgradeBlock(2);
        }
    }

    static {
        cardStrings = CardCrawlGame.languagePack.getCardStrings(ID);
    }
}

